package com.healthbox.appointmentservice.common;

import com.healthbox.appointmentservice.DVO.AppointmentInfoDVO;
import lombok.Builder;
import lombok.Data;

import java.time.format.DateTimeFormatter;

/**
 * @author pengpeng
 * @date 2022/5/22
 */
@Data
@Builder
public class InfoMessage {
    private Long id;
    private String address;
    private String time;
    private String phone;

    public static InfoMessage fromAppointmentDVO(AppointmentInfoDVO appointmentInfoDVO) {
        return InfoMessage.builder()
                .id(appointmentInfoDVO.getALId())
                .address(appointmentInfoDVO.getAddress())
                .time(
                        appointmentInfoDVO.getDate().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日 "))
                        + appointmentInfoDVO.getStartTime().format(DateTimeFormatter.ofPattern(("hh:mm-")))
                                + appointmentInfoDVO.getEndTime().format(DateTimeFormatter.ofPattern("hh:mm")))
                .phone(appointmentInfoDVO.getUserPhone())
                .build();
    }
}
